package com.atguigu.gmall.controller;

import com.atguigu.gmall.constant.MqConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class SimulateQuartzController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //1.发送上架秒杀商品通知
    @GetMapping("sendMsgToScanSeckill")
    public String sendMsgToScanSeckill(){
        rabbitTemplate.convertAndSend(MqConst.SCAN_SECKILL_EXCHANGE,  MqConst.SCAN_SECKILL_ROUTE_KEY, "");
        return "success";
    }
    //2.发送清理秒杀善后通知
    @GetMapping("sendMsgToClearRedis")
    public String sendMsgToClearRedis(){
        rabbitTemplate.convertAndSend(MqConst.CLEAR_REDIS_EXCHANGE,  MqConst.CLEAR_REDIS_ROUTE_KEY, "");
        return "success";
    }


}
